<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>总部列表</title>
</head>
<body>
<form id="pagerForm" method="post" action="${pageContext.request.contextPath}/hq/list">
    <input type="hidden" name="pageNum" value="1" />  
    <input type="hidden" name="numPerPage" value="${collectionTO.pageSize}" />
    <input type="hidden" name="hqName" value="${searchCriteria.hqName}" />
    <input type="hidden" name="legalRepresentative" value="${searchCriteria.legalRepresentative}" />
    <input type="hidden" name="contactsName" value="${searchCriteria.contactsName}" />
    <input type="hidden" name="phoneNum" value="${searchCriteria.phoneNum}" />
    <input type="hidden" name="provinceId" value="${searchCriteria.provinceId}" />
    <input type="hidden" name="cityId" value="${searchCriteria.cityId}" />
</form>
<div class="pageHeader" id="hq_search_div">
	<form onsubmit="return navTabSearch(this);" action="${pageContext.request.contextPath}/hq/list" method="post">
	<div class="searchBar">
		<ul class="searchContent">
			<li>
				<label>总部名称</label>
				<input style="width:75px" type="text" name="hqName"  value="${searchCriteria.hqName}" />
			</li>
			<li>
				<label>法人/代理人</label>
				<input style="width:75px" type="text" name="legalRepresentative"  value="${searchCriteria.legalRepresentative}" />
			</li>
			<li>
				<label>联系人</label>
				<input style="width:75px" type="text" name="contactsName" value="${searchCriteria.contactsName}" />
			</li>
			<li>
				<label>电话</label>
				<input style="width:75px" type="text" name="phoneNum" value="${searchCriteria.phoneNum}" />
			</li>
			
		</ul>
		<ul class="searchContent">
			<li>
				<label>省份</label>
				 <select data-placeholder="省份" id="provinceId" name="provinceId" class="select" >
				 	<option value="">选择省份</option>
	           </select>
	          	<input type="hidden" id="old_provinceId" value="${searchCriteria.provinceId}"/>
			</li>
			<li>
				<label>城市</label>
	           <select data-placeholder="城市" name="cityId" id="cityId" class="form-control" data-rel="chosen">
	           		<option value="">选择城市</option>
	          	</select>
	           <input type="hidden" id="old_cityId" value="${searchCriteria.cityId}"/>
			</li>
		</ul>
		<div class="subBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">检索</button></div></div></li>
				<!-- <li><a class="button" href="demo_page6.html" target="dialog" mask="true" title="查询框"><span>高级检索</span></a></li> -->
			</ul>
		</div>
	</div>
	</form>
</div>


<div class="pageContent">
	<div class="panelBar">
		<div class="pages">
			<span>显示</span>
			<select class="combox" name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
	 			<option value="5" <c:if test="${collectionTO.pageSize==5}">selected</c:if>>5</option>
	 			<option value="10" <c:if test="${collectionTO.pageSize==10}">selected</c:if>>10</option>
			</select>
			<span>条，共${totalCount}条</span>
		</div>
		<div class="pagination" targetType="navTab" totalCount="${totalCount}" numPerPage="${collectionTO.pageSize}" pageNumShown="10" currentPage="${collectionTO.pageNo}"></div>
	</div>
	<div class="panelBar">
		<ul class="toolBar">
			<li class=""><a target="navTab" href="${pageContext.request.contextPath}/hq/toAdd" class="add"><span>添加</span></a></li>
			<li class="line">line</li>
			<li class=""><a warn="请选择一条数据" target="navTab" href="${pageContext.request.contextPath}/hq/toUpdate?hqId={sid_user}" class="edit"><span>修改</span></a></li>
			<li class="line">line</li>
			<li><a warn="请选择一条数据" title="确定要删除吗？" target="ajaxTodo" href="${pageContext.request.contextPath}/hq/del?hqId={sid_user}" class="delete"><span>删除</span></a></li>
			<li class="line">line</li>
			<li><a warn="请选择一条数据" target="navTab" href="${pageContext.request.contextPath}/station/toAdd?hqId={sid_user}" class="add"><span>新增加站点</span></a></li>
			<li class="line">line</li>
			<li><a warn="请选择一条数据" target="navTab" href="${pageContext.request.contextPath}/prconfig/toPRConfig?hqId={sid_user}" class="icon"><span>配置油品</span></a></li>
			<li class="line">line</li>
			<li><a warn="请选择一条数据" target="navTab" href="${pageContext.request.contextPath}/note/toCharge?hqId={sid_user}" class="icon"><span>短信充值</span></a></li>
			<li class="line">line</li>
			<li><a warn="请选择一条数据" target="navTab" href="${pageContext.request.contextPath}/note/listSendHistory?hqId={sid_user}" class="icon"><span>发送短信记录</span></a></li>
		</ul>
	</div>
	<table class="list" width="100%" layoutH="116">
		<thead>
			<tr>
				<th width="80">油站总部编码</th>
				<th width="80">油站总部名</th>
				<th width="80">登录名称</th>
				<th width="80">营业执照编号</th>
				<th width="80">营业执照编号</th>
				<th width="80">法人/代理人</th>
				<th width="60" align="center">地址</th>
				<th width="60">联系人</th>
				<th width="80">电话</th>
				<th width="80">邮箱</th>
				<th width="80">备注</th>
				<th width="80">创建时间</th>
<!-- 				<th width="80">操作</th> -->
			</tr>
		</thead>
	<tbody>
		<volist id="vo" name="list">
			<c:forEach items="${collectionTO.list}" var="hqBaseInfoTO" varStatus="status">
				<tr target="sid_user" rel="${hqBaseInfoTO.hqId}">
					<td>${hqBaseInfoTO.hqId}</td>
					<td>${hqBaseInfoTO.hqName}</td>
					<td>${hqBaseInfoTO.loginName}</td>
					<td>${hqBaseInfoTO.registeredName}</td>
					<td>${hqBaseInfoTO.registeredNumber}</td>
					<td>${hqBaseInfoTO.legalRepresentative}</td>
					<td>${hqBaseInfoTO.province}${hqBaseInfoTO.city}${hqBaseInfoTO.address}</td>
					<td>${hqBaseInfoTO.contactsName}</td>
					<td>${hqBaseInfoTO.phoneNum}</td>
					<td>${hqBaseInfoTO.email}</td>
					<td>${hqBaseInfoTO.memo}</td>
					<td>
						<fmt:formatDate value="${hqBaseInfoTO.createdTime}" type="date" dateStyle="long" />
					</td>
				</tr>
			</c:forEach>
			</volist>
		</tbody>
	</table>
</div>
</body>
<script type="text/javascript">
$(document).ready(function () {
 	
 	var doc = $("#hq_search_div");
	 var old_provinceId = $(doc).find("#old_provinceId").val();
 	$.post("${pageContext.request.contextPath}/address/listProvinces", 
 		   function(data){
 		 if(data.code == 200){
                 var result = "<option value=''>选择省份</option>";
                 $.each(data.list,function(n,value){
                	 if(old_provinceId*1 == value.provinceId*1){
                  		result +="<option value='"+value.provinceId+"' selected='selected'>"+value.province+"</option>";
                  	}else{
                        result +="<option value='"+value.provinceId+"'>"+value.province+"</option>";
                  	}
                 });
                 $(doc).find("#provinceId").html('');
                 $(doc).find("#provinceId").append(result);
                 get_city();
             }
 		   });
 	  

 	$(doc).find("#provinceId").change(function(){get_city()});

});
 	
 	function get_city() {
 		var doc = $("#hq_search_div");
 		
		var provinceId = $(doc).find("#provinceId").val()
         var result = "<option value=''>选择城市</option>";
		if(provinceId == ""){
			$(doc).find("#cityId").html('');
			$(doc).find("#cityId").append(result);
			return;
		}
    	$.post("${pageContext.request.contextPath}/address/listCity",{provinceId:$(doc).find("#provinceId").val()}, 
		   function(data){
   			var old_cityId = $(doc).find("#old_cityId").val();
   		 if(data.code == 200){
                   $.each(data.list,function(n,value){
	                   	if(old_cityId*1 == value.cityId*1){
	                   		result +="<option value='"+value.cityId+"' selected='selected'>"+value.city+"</option>";
	                   	}else{
	                         result +="<option value='"+value.cityId+"'>"+value.city+"</option>";
	                   	}
                   });
                   $(doc).find("#cityId").html('');
                   $(doc).find("#cityId").append(result);
               }
		   });
    }
function dialogAjaxDone(json){
    DWZ.ajaxDone(json);
    if (json.statusCode == DWZ.statusCode.ok){
        if (json.navTabId){
            navTab.reload(json.forwardUrl, {navTabId: json.navTabId});
        } else if (json.rel) {
            var $pagerForm = $("#pagerForm", navTab.getCurrentPanel());
            var args = $pagerForm.size()>0 ? $pagerForm.serializeArray() : {}
            navTabPageBreak(args, json.rel);
        }
        if ("closeCurrent" == json.callbackType) {
            $.pdialog.closeCurrent();
        }
    }
}
</script>
</html>